import 'babel-polyfill'
import promise from 'es6-promise' // 兼容 Promise
import Vue from 'vue'
import VueRouter from 'vue-router'
import Center from './center.vue'

promise.polyfill()

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Center',
    component: Center
  },
  {
    path: '/addInfo',
    name: 'Info',
    component: function () { return import('./info.vue') }
  },
  {
    path: '/jobList',
    name: 'JobList',
    component: function () { return import('./jobList.vue') }
  },
  {
    path: '/addJob',
    name: 'AddJob',
    component: function () { return import('./addJob.vue') }
  },
  {
    path: '/joinList',
    name: 'JoinList',
    component: function () { return import('./joinList.vue') }
  },
  {
    path: '/meet',
    name: 'Meet',
    component: function () { return import('./meet.vue') }
  },
  {
    path: '/changepwd',
    name: 'Changepwd',
    component: function () { return import('./changepwd.vue') }
  }

]

const router = new VueRouter({
  routes
})
router.beforeEach((to, from, next) => {
  if (!localStorage.getItem('md_userInfo')) {
    window.location.href = 'index.html'
    return
  }
  next()
})
export default router
